package com.salon.modules.job.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.salon.common.http.response.PageResult;
import com.salon.common.utils.Query;
import com.salon.modules.job.entity.ScheduleJobLogEntity;
import com.salon.modules.job.mapper.ScheduleJobLogMapper;
import com.salon.modules.job.service.ScheduleJobLogService;
import java.util.List;
import java.util.Map;
import org.apache.commons.lang.StringUtils;
import org.springframework.stereotype.Service;

@Service("scheduleJobLogService")
public class ScheduleJobLogServiceImpl extends
        ServiceImpl<ScheduleJobLogMapper, ScheduleJobLogEntity> implements ScheduleJobLogService {

    @Override
    public PageResult<ScheduleJobLogEntity> listByPage(Map<String, Object> params) {
        IPage<ScheduleJobLogEntity> pageParams = new Query<ScheduleJobLogEntity>().getPage(params);
        String jobId = (String) params.get("jobId");
        LambdaQueryWrapper<ScheduleJobLogEntity> queryWrapper = new LambdaQueryWrapper<>();
        queryWrapper.like(StringUtils.isNotBlank(jobId), ScheduleJobLogEntity::getJobId, jobId);
        IPage<ScheduleJobLogEntity> page = this.page(pageParams, queryWrapper);
        List<ScheduleJobLogEntity> resultList = page.getRecords();
        return new PageResult<>(page.getTotal(), page.getCurrent(), page.getSize(), resultList);
    }

}
